<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // const arr =[1,2,3,4,5,6]
        // const arr2 = arr.reduce((newArr,currVal) =>{
        //     newArr.push(currVal + 1)
        //     return newArr
        //     console.log(newArr)
        // },[])
        // console.log(arr2)
        const products = [
  {
    price: 323,
    quantity: 9
  },
  {
    price: 99,
    quantity: 7
  },
  {
    price: 1362,
    quantity: 78
  }
]
        let res = 0 
        products.forEach(i =>{
            res += i.price * i.quantity
        })
        console.log(res)
        // reduce的写法：
        // const res = products.reduce((res,currVal) =>{
        //     res += currVal.price + currVal.quantity
        //     return res
        // },0)
        // console.log(res)    //1878
    </script>
</body>
</html>